//对axios进行二次封装
import axios from "axios";
//引入进度条插件
import nprogress from "nprogress";
//引入进度条样式
import "nprogress/nprogress.css";
const requests = axios.create({
    baseURL: "/mock",
    timeout: 5000
});
//请求拦截器
requests.interceptors.request.use((config) => {
    //进度条开始
    nprogress.start();
    //config：配置对象，对象中"header请求头"这个属性很重要
    return config;
});
//响应拦截器
requests.interceptors.response.use((res) => {
    //进度条结束
    nprogress.done();
    //成功回调
    return res.data;
}, (err) => {
    //失败回调
    return Promise.reject(new Error('faile'));
})
//对外暴露
export default requests;